export interface $RefSchema {
  $ref: string
}

export interface StringSchema {
  type: 'string'
  description?: string
}

export interface NumberSchema {
  type: 'integer' | 'number' | 'int32' | 'int64'
  description?: string
}

export interface ObjectSchema {
  type: 'object'
  required: string[]
  properties: Record<string, Schema>
  title: string
  description?: string
}

export interface ArraySchema {
  type: 'array'
  items: Schema
  description?: string
}

export interface BooleanSchema {
  type: 'boolean'
  description?: string
}

export type NormalSchema = StringSchema | NumberSchema | BooleanSchema
export type QuoteSchema = ObjectSchema | ArraySchema

export type Schema = $RefSchema | NormalSchema | QuoteSchema

export interface RequestParameter {
  name: string
  in: 'path' | 'query'
  description: string
  required: boolean
  schema: Schema
}

export interface RequestBody {
  content: Record<string, { schema: Schema }>
}

export interface Response {
  description?: string
  content?: Record<string, { schema: Schema }>
}

export interface ApiConfig {
  tags: string[]
  summary: string
  operationId: string
  parameters: RequestParameter[]
  requestBody: RequestBody
  responses: Record<string, Response>
  path: string
  method: string
}

export interface ApiDocs {
  openapi: string
  info: { title: string; description: string }
  tags: { name: string; description: string }[]
  paths: Record<string, Record<'post' | 'get' | 'put' | 'delete', ApiConfig>>
  components: { schemas: Record<string, ObjectSchema> }
}

export interface Source {
  operationIdMap: {
    [k: string]: ApiConfig
  }
  paths: string[]
  components: Record<string, ObjectSchema>
}
